//
//  BBDHealthKnowledgeViewController.m
//  棒棒哒
//
//  Created by rimi on 15/8/3.
//  Copyright (c) 2015年 rimi. All rights reserved.
//

#import "BBDHealthKnowledgeViewController.h"
#import "Config.h"

#import "BBDTabbarViewController.h"
#import "DetailHealthyBookViewController.h"
#import "MainSearchViewController.h"
#import "DetailMedicineInfomationViewController.h"
#import "DetailHealthyInfomationViewController.h"

#define SELF_WIDTH (self.view.bounds.size.width)
#define SELF_HEIGHT (self.view.bounds.size.height)
#define TABBAR_HEIGHT ([BBDTabbarViewController shareTabBarController].tabBar.bounds.size.height)
@interface BBDHealthKnowledgeViewController ()
@property(nonatomic ,strong)UICollectionView *collectionView;
@property(nonatomic ,assign)BOOL             tabbarShow;


@end

@implementation BBDHealthKnowledgeViewController


-(void)viewWillAppear:(BOOL)animated
{

    self.tabBarController.tabBar.hidden = NO;
    self.navigationController.navigationBar.translucent = YES;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self initializeDataSource];
    [self initializeUserInterface];
    [self netWorkRequest];
}
-(void)initializeDataSource
{
    
    
}

-(void)initializeUserInterface
{
//    CGFloat buttonDistance = [BBDTabbarViewController shareTabBarController].tabBar.bounds.size.height;
    
    [BBDTabbarViewController shareTabBarController].tabBar.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, TABBAR_HEIGHT);
    
    self.view.backgroundColor = [UIColor whiteColor];

    //疾病信息
    UIButton *diseaseInfomation = [CustomButton buttonWithFrame:CGRectMake(SCREEN_WIDTH/2, SCREEN_HEIGHT - SCREEN_WIDTH, SCREEN_WIDTH * 0.5, SCREEN_WIDTH * 0.5) Title:@"疾病信息" BackGroudImage:IMAGNAME(@"") BackGroundColor:[UIColor colorWithRed:0.702 green:0.920 blue:0.921 alpha:1.000] TextColor:[UIColor redColor] CornerRadius:0 BorderWidth:1 BorderColor:[UIColor clearColor]];
    diseaseInfomation.alpha = 0.5;
    [diseaseInfomation addTarget:self action:@selector(handleButtonDiseaseInfomation) forControlEvents:64];
    
    
    [self.view addSubview:diseaseInfomation];
    //药品大全
    UIButton *medicineInfomation = [CustomButton buttonWithFrame:CGRectMake(0, SCREEN_HEIGHT - SCREEN_WIDTH/2, SCREEN_WIDTH * 0.5, SCREEN_WIDTH * 0.5) Title:@"药品大全" BackGroudImage:IMAGNAME(@"") BackGroundColor:[UIColor colorWithRed:0.926 green:0.730 blue:0.931 alpha:1.000] TextColor:[UIColor redColor] CornerRadius:0 BorderWidth:1 BorderColor:[UIColor clearColor]];
    [self.view addSubview:medicineInfomation];
    
    //健康图书
    UIButton *healthyBook = [CustomButton buttonWithFrame:CGRectMake(0, SCREEN_HEIGHT - SCREEN_WIDTH , SCREEN_WIDTH /2, SCREEN_WIDTH /2) Title:@"健康图书" BackGroudImage:IMAGNAME(@"") BackGroundColor:[UIColor colorWithRed:0.913 green:0.933 blue:0.729 alpha:1.000] TextColor:[UIColor redColor] CornerRadius:0 BorderWidth:1 BorderColor:[UIColor clearColor]];
    //设置阴影
    healthyBook.layer.shadowColor = [UIColor blackColor].CGColor;
    healthyBook.layer.shadowOffset = CGSizeMake(1, 1);
    healthyBook.layer.shadowOpacity = 0.7;
    //点击事件
    [healthyBook addTarget:self action:@selector(handleButtonHealthyBook:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:healthyBook];
    
    //健康知识
    
    UIButton *healthyInfomation = [CustomButton buttonWithFrame:CGRectMake(SCREEN_WIDTH/2,SCREEN_HEIGHT - SCREEN_WIDTH/2, SCREEN_WIDTH * 0.5, SCREEN_WIDTH * 0.5) Title:@"药品大全" BackGroudImage:IMAGNAME(@"") BackGroundColor:[UIColor colorWithRed:0.625 green:0.919 blue:0.683 alpha:1.000] TextColor:[UIColor redColor] CornerRadius:0 BorderWidth:1 BorderColor:[UIColor clearColor]];
    healthyInfomation.layer.shadowColor = [UIColor blackColor].CGColor;
    healthyInfomation.layer.shadowOffset = CGSizeMake(-1 ,-1);
    healthyInfomation.layer.shadowOpacity = 0.70;
    [self.view addSubview:healthyInfomation];
//    healthyInfomation.transform = CGAffineTransformMakeRotation(M_1_PI/2);

    
    
    
    //中间button
    UIButton *showTabbar = [CustomButton buttonWithFrame:CGRectNull Title:@"" BackGroudImage:nil BackGroundColor:NAVCOLOR TextColor:nil CornerRadius:50 BorderWidth:0 BorderColor:nil];
    showTabbar.bounds = CGRectMake(0, 0, 100, 100);
    showTabbar.center = CGPointMake(SCREEN_WIDTH * 0.5, SCREEN_HEIGHT - SCREEN_WIDTH * 0.5);
    [showTabbar addTarget:self action:@selector(handleButtonShowTabbar) forControlEvents:64];
    [self.view addSubview:showTabbar];

    
    
    
}


-(void)handleButtonShowTabbar
{
    if (_tabbarShow) {
    
        [UIView animateWithDuration:1 delay:0 usingSpringWithDamping:1 initialSpringVelocity:1 options:UIViewAnimationOptionLayoutSubviews animations:^{
                    [BBDTabbarViewController shareTabBarController].tabBar.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, TABBAR_HEIGHT);
        } completion:nil];

    }else{
        [UIView animateWithDuration:1 delay:0 usingSpringWithDamping:1 initialSpringVelocity:1 options:UIViewAnimationOptionLayoutSubviews animations:^{
               [BBDTabbarViewController shareTabBarController].tabBar.frame = CGRectMake(0, SCREEN_HEIGHT - TABBAR_HEIGHT, SCREEN_WIDTH, TABBAR_HEIGHT);
        } completion:nil];
    }

    _tabbarShow = !_tabbarShow;

}




-(void)handleButtonHealthyBook:(UIButton *)sender
{
    DetailHealthyBookViewController *detailHealthyBook = [[DetailHealthyBookViewController alloc]init];
    [self.navigationController pushViewController:detailHealthyBook animated:YES];

}

-(void)handleButtonDiseaseInfomation
{
    MainSearchViewController *detailDisease = [[MainSearchViewController alloc]init];
    [self.navigationController pushViewController:detailDisease animated:YES];

}



-(void)netWorkRequest
{
    
    
}

-(void)loadAfterNetRequest
{
    
    
}









@end
